package com.ty.day4;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/27 11:19
 */
public class SetDemo01 {
    public static void main(String[] args) {
       /* HashSet<Point> hashSet = new HashSet<>();
        hashSet.add(new Point(1,2));
        hashSet.add(new Point(5,6));
        hashSet.add(new Point(7,8));
        hashSet.add(new Point(3,4));
        hashSet.add(new Point(5,6));
        hashSet.add(new Point(7,8));
        for (Point point : hashSet) {
            System.out.println(point.toString());
        }
        System.out.println(hashSet.contains(new Point(1, 2)));*/
        ArrayList<Integer> list = new ArrayList<>();
        Random random = new Random();
        while (list.size()<=20){
            int i = random.nextInt(100);
            if (!list.contains(i)){
                list.add(i);
            }
        }
        System.out.println(list);
        HashSet<Integer> set = new HashSet<>();
        while (set.size()<=6){
            set.add(random.nextInt(1000));
        }
        System.out.println(set);
        Integer[] a = new Integer[]{1,3,2,3,2,1,2,3,5,10,6,7,8,0};
        HashSet<Object> set1 = new HashSet<>();
        for (Integer i : a) {
            set1.add(i);
        }
        System.out.println(set1);
    }
}
